

import request from '../../utils/request.js'


//存储模块中的数据
const state = {
	homeInfo:{},
	homeCardList:[]
}
const actions = {
	//获取home页面的数据
   async getHomeInfoData({commit}){
	   try{
		   const result = await request({url:'/getIndexData'})
		   commit('SET_HOME_INFO_DATA',result)
		  
	   }catch(e){
		   alert('获取页面内容出错了')
	   }
   },
   //获取home页面导航栏切换之后的数据
   async getHomeCardList({commit}){
	   try{
		   const result = await request({url:'/getIndexCateList'})
		   commit('SET_HOME_CARD_LIST',result)
	   }catch(e){
		   
	   }
   }
   }

const mutations = {
	//存储homeInfo数据
	SET_HOME_INFO_DATA(state,homeInfo){
		state.homeInfo = homeInfo
	},
	//存储导航栏切换的数据
	SET_HOME_CARD_LIST(state,categoryList){
		state.homeCardList = categoryList
	}
	
}
const getters = {
	//导航标题列表
	navList(state){
		return  (state.homeInfo.kingKongModule || {}).kingKongList || []
	},
	//口号标语
	sloganList(state){
	return state.homeInfo.policyDescList || []
	},
	//楼层数据
	floorsList(state){
			return state.homeInfo.categoryModule || []
	},
}

export default{
	namespaced:true,
	state,
	actions,
	mutations,
	getters
}